<template>
  <div>
    章节标题<el-input v-model="form.title" />
    第几节<el-input v-model="form.tcount" />
    选择课程<select v-model="form.cid" >
        <option v-for="i  in  clist" :value="i.id">{{i.name}}</option>
    </select>
    上传图片
    <el-upload action="#" :before-upload="upload">
    <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
    </el-upload>
        <el-button @click="submit">提交</el-button>
  </div>
</template>

<script>
export default {
    data(){
        return{
            form:{url:""},
            clist:[{'id':22,'name':'python'},{'id':24,'name':'java'}]
        }
    },
    methods:{
        upload(file){
            var data = new FormData()
            data.append('file',file)
            this.axios.post("course/upload",data).then(res=>{
                this.form.url = res.data.url
            })
        },
        submit(){
            this.axios.post('course/addjie',this.form).then(res=>{
                 
            })
        }
    }
}
</script>

<style>

</style>